package Thread;

/**
 * Created with IntelliJ IDEA.
 * Description:多线程实现使用方法四：匿名内部类实现Runnable接口
 */
public class ThreadDemo4 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                while(true) {
                    System.out.println("hello");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }

                }
            }
        });
        thread.start();
        while(true) {
            System.out.println("world");
            Thread.sleep(1000);
        }
    }
}
